const obj1 = {
  age: 18,
  name: 'zg',
  study: function() {
    console.log("i am study");
  },
  friends: ['lucy', 'jam']
};
let obj2 = Object.create(obj1, {
  age: {
    writable: true,
    enumerable: true,
    value: 66
  }
});
console.log(obj2);
/** 结果
{
    "age": 66
}
*/
console.log(obj2.__proto__);
/** 结果
{
    "age": 18,
    "name": "zg",
    "friends": [
        "lucy",
        "jam"
    ]
}
*/

const obj3 = Object.create(null, {
  age: {
    writable: true,
    enumerable: true,
    value: 66
  },
  name: {
    writable: true,
    enumerable: true,
    value: "zg"
  }
});
console.log(obj3);
/** 结果
{
  "age": 66,
  "name": "zg"
}
*/
console.log(obj3.__proto__);
/** 结果
undefined
*/



// const ages = { alice: 18, bob: 27 };
// function hasPerson(name) {
//   return name in ages;
// }

// function getAge(name) {
//   return ages[name];
// }

// console.log(hasPerson("hasOwnProperty")); 
// /** 结果
// true
// */
// console.log(getAge("toString")); 
// /** 结果
// [Function: toString]
// */

const ages = Object.create(null);
function hasPerson(name) {
  return name in ages;
}

function getAge(name) {
  return ages[name];
}

console.log(hasPerson("hasOwnProperty")); 
/** 结果
false
*/
console.log(getAge("toString")); 
/** 结果
undefined
*/


function Person(age, name) {
  this.age = age;
  this.name = name;
}

function Student(uid) {
  this.uid = uid;
}

const person1 = new Person(18, 'zg');
Student.prototype = Object.create(Person.prototype);
console.log(Student.prototype);
/** 结果
Person {}
*/
